import json

# Python 字典类型转换为JSON对象

data = {
    'no': 2,
    'name': 'Runoob',
    'url': 'http://www.runoob.com'
}

json_str = json.dumps(data)
print('Python 原始数据：', repr(data))
print('JSON对象：', json_str)

data2 = json.loads(json_str)

print("data2['name']: ",data2['name'])
print("data2['url']: ",data2['url'])

with open('data.json','w') as f:
    json.dump(data,f)

with open('data.json','r+') as f:
    data = json.load(f)

print(data)

